/*
 * bootloader_support.c
 *
 *  Created on: 25.10.2011
 *      Author: g.kruglov
 */

#include "bootloader_support.h"
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "USB.h"
#include <avr/wdt.h>
#include <avr/io.h>

typedef void (*AddrPtr_t)(void) __attribute__ ((noreturn));

void StartBootloader(void) {
    AddrPtr_t JumpToBootloader = (AddrPtr_t)(0x3800 << 1);
    cli();
    USB_Detach();
    USB_Controller_Disable();
    USB_PLL_Off();
    _delay_ms(540);         // wait for USB to shutdown
    TIMSK1 = 0;
    TIMSK0 = 0;
    JumpToBootloader();
}
